package kr.hyunist.androidcomplete01saeildamil.ch13;

import java.text.*;
import java.util.*;

import kr.hyunist.androidcomplete01saeildamil.*;
import android.app.*;
import android.os.*;
import android.view.*;
import android.widget.*;

public class DateTimeEx extends Activity {
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.datetimetest);
		
		Refresh();
	}

	public void mOnClick(View v){
		Refresh();
	}
	
	private void Refresh() {
		StringBuilder time = new StringBuilder();
		
		Calendar cal = new GregorianCalendar();
		cal.add(Calendar.DAY_OF_MONTH, -7);
		//cal.set(int field, int value);
		//cal.set(Calendar.DAY_OF_MONTH, cal.get(Calendar.DAY_OF_MONTH) - 7);
		Date calDate = cal.getTime();
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy.MM.dd EEE");
		time.append("일주일전 : " + sdf.format(calDate) + "\n");
		
		
		
		TextView result = (TextView) findViewById(R.id.datetimetesttv);
		result.setText(time.toString());
	}
}
